package com.xiaoyu.izf.util;

import java.text.DecimalFormat;

public class HashrateUtil {
    public static String getReadableHashRateString(double hashrate){
        int i=0;
        String[] byteUnits = {" H", " KH", " MH", " GH", " TH", " PH" };
        while (hashrate > 1000){
            hashrate = hashrate / 1000;
            i++;
        }
        DecimalFormat df = new DecimalFormat("#.00");
        return df.format(hashrate)+byteUnits[i]+"/s";
    }
}
